<html><body bgcolor="#000000" text="#ffffff"><table><tr><td colspan="2"><h3>Problem Statement</h3></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><p>
John and Brus have become very famous people all over the world, especially in Bolivia.
Once they decided to visit their fan club in Bolivia.
John has an old map of Bolivia which shows all of its cities and the roads connecting them.
All roads are bidirectional, meaning they can be traversed in both directions.
Since the map is old, it's possible that some additional roads have been built since the map was produced.
However, roads are never destroyed in Bolivia, so all the roads on the map still exist.
</p>

<p>
Brus has discovered on the Internet that each pair of Bolivian cities now has exactly one simple path connecting them.
A path between cities A and B is a sequence of cities starting with A and ending with B such that there's a road between each pair of consecutive cities in the sequence.
The path is considered simple if it consists of distinct cities.
</p>

<p>
John and Brus have decided to add some new roads to the old map in such a way that the resulting map satisfies this condition.
They can only add a road between a pair of cities if that road did not already exist in the old map.
They can't add more than one road between the same pair of cities, and they can't add a road that leads from a city to itself.
All added roads must be bidirectional.
</p>

<p>
You are given a vector &lt;string&gt; <b>map</b>.
The j-th character of the i-th element of <b>map</b> will be 'Y' if there is a road between the i-th and j-th cities on the old map, or 'N' otherwise.
Return the number of ways John and Brus can add new roads to the old map.
Two ways are considered different if the sets of added roads are distinct.
The order in which roads are added does not matter.
</p>
</td></tr><tr><td colspan="2"><h3>Definition</h3></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td>Class:</td><td>TheCitiesAndRoadsDivTwo</td></tr><tr><td>Method:</td><td>find</td></tr><tr><td>Parameters:</td><td>vector &lt;string&gt;</td></tr><tr><td>Returns:</td><td>int</td></tr><tr><td>Method signature:</td><td>int find(vector &lt;string&gt; map)</td></tr><tr><td colspan="2">(be sure your method is public)</td></tr></table></td></tr><tr><td>&#160;&#160;&#160;&#160;</td></tr><tr><td></td></tr><tr><td colspan="2"><h3>Notes</h3></td></tr><tr><td align="center" valign="top">-</td><td>The answer will always fit in signed 32-bit integer.</td></tr><tr><td colspan="2"><h3>Constraints</h3></td></tr><tr><td align="center" valign="top">-</td><td><b>map</b> will contain between 1 and 9 elements, inclusive.</td></tr><tr><td align="center" valign="top">-</td><td>Each element of <b>map</b> will contain exactly n characters, where n is the number of elements in <b>map</b>.</td></tr><tr><td align="center" valign="top">-</td><td>Each character of <b>map</b> will be either 'Y' of 'N'.</td></tr><tr><td align="center" valign="top">-</td><td>The j-th character of the i-th element of <b>map</b> will be equal to the j-th character of the i-th element of <b>map</b>.</td></tr><tr><td align="center" valign="top">-</td><td>The i-th character of the i-th element of <b>map</b> will be 'N'.</td></tr><tr><td align="center" valign="top">-</td><td>There will be at least one way for John and Brus to add new roads to the old map.</td></tr><tr><td colspan="2"><h3>Examples</h3></td></tr><tr><td align="center" nowrap="true">0)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{&quot;NN&quot;,
 &quot;NN&quot;}</pre></td></tr></table></td></tr><tr><td><pre>Returns: 1</pre></td></tr><tr><td><table><tr><td colspan="2">The only way is to connect two cities with a road.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">1)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{&quot;NY&quot;,
 &quot;YN&quot;}</pre></td></tr></table></td></tr><tr><td><pre>Returns: 1</pre></td></tr><tr><td><table><tr><td colspan="2">Adding no roads is a possible valid way.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">2)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{&quot;NNY&quot;,
 &quot;NNN&quot;,
 &quot;YNN&quot;}</pre></td></tr></table></td></tr><tr><td><pre>Returns: 2</pre></td></tr><tr><td><table><tr><td colspan="2">There are two possible ways - connect the second city with the first one or with the third one.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">3)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{&quot;NYNN&quot;,
 &quot;YNNN&quot;,
 &quot;NNNY&quot;,
 &quot;NNYN&quot;}</pre></td></tr></table></td></tr><tr><td><pre>Returns: 4</pre></td></tr><tr><td><table><tr><td colspan="2"></td></tr></table></td></tr></table></td></tr></table><p>This problem statement is the exclusive and proprietary property of TopCoder, Inc.  Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited.  (c)2003, TopCoder, Inc.  All rights reserved.  </p></body></html>
